package com.jmp.service.api.admin.dto;

import lombok.Builder;
import lombok.Data;
import one.stand.dto.PageResponse2;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.Objects;

/**
 * @author cjr
 */
@Data
@Builder
public class BannerListVo {
    private PageResponse2<Banner> bannerPage;

    @Data
    @Builder
    public static class Banner {
        private Integer id;
        private Integer companyId;
        private Integer bannerType;
        private String source;
        private Integer type;
        private Integer event;
        private String eventId;
        private String memo;
        private Integer sort;
        private Integer status;
        private Date createTime;
        private Integer refId;
        private Integer width;
        private Integer height;
        private Integer selectBannerId;

        public BigDecimal getSizeRate() {
            return Objects.nonNull(getHeight()) && Objects.nonNull(getWidth()) ? new BigDecimal(getHeight()).divide(new BigDecimal(getWidth()), 2, RoundingMode.HALF_UP) : null;
        }
    }
}
